From 729715465a726c1bfd8a39b9bd84d7d888d3827a Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Mon, 8 May 2006 18:10:23 +0000 Subject: [PATCH] Elide (_x) in the middle of the string, too. (#323956, Abel Cheung) 2006-05-08 Matthias Clasen * gtk/gtktoolbar.c (_gtk_toolbar_elide_underscores): Elide (_x) in the middle of the string, too. (#323956, Abel Cheung) --- ChangeLog | 3 +++ ChangeLog.pre-2-10 | 3 +++ gtk/gtktoolbar.c | 32 +++++++++++++++++--------------- 3 files changed, 23 insertions(+), 15 deletions(-) diff --git a/ChangeLog b/ChangeLog index c4680a469f..68482c1057 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,8 @@ 2006-05-08 Matthias Clasen + * gtk/gtktoolbar.c (_gtk_toolbar_elide_underscores): Elide (_x) in the middle + of the string, too. (#323956, Abel Cheung) + * gtk/gtkuimanager.c (update_node): Fix tooltips. * configure.in: Require Pango 1.13.0 diff --git a/ChangeLog.pre-2-10 b/ChangeLog.pre-2-10 index c4680a469f..68482c1057 100644 --- a/ChangeLog.pre-2-10 +++ b/ChangeLog.pre-2-10 @@ -1,5 +1,8 @@ 2006-05-08 Matthias Clasen + * gtk/gtktoolbar.c (_gtk_toolbar_elide_underscores): Elide (_x) in the middle + of the string, too. (#323956, Abel Cheung) + * gtk/gtkuimanager.c (update_node): Fix tooltips. * configure.in: Require Pango 1.13.0 diff --git a/gtk/gtktoolbar.c b/gtk/gtktoolbar.c index 98535add88..8aa4e5970d 100644 --- a/gtk/gtktoolbar.c +++ b/gtk/gtktoolbar.c @@ -4877,38 +4877,40 @@ gchar * _gtk_toolbar_elide_underscores (const gchar *original) { gchar *q, *result; - const gchar *p; + const gchar *p, *end; + gsize len; gboolean last_underscore; - gint s; if (!original) return NULL; - s = strlen (original); - q = result = g_malloc (s + 1); + len = strlen (original); + q = result = g_malloc (len + 1); last_underscore = FALSE; - for (p = original; *p; p++) + end = original + len; + for (p = original; p < end; p++) { if (!last_underscore && *p == '_') last_underscore = TRUE; else { last_underscore = FALSE; - *q++ = *p; + if (*p != '_' && original + 2 <= p && p + 1 <= end && p[-2] == '(' && p[1] == ')') + { + q--; + *q = '\0'; + p++; + } + else + *q++ = *p; } } + if (last_underscore) + *q++ = '_'; + *q = '\0'; - - if (s > 4) - { - if (original[s - 4] == '(' && - original[s - 3] == '_' && - original[s - 1] == ')') - q[-3] = '\0'; - } - return result; } -- 2.30.2